package database.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import database.pojo.RecordFileInfo;


public class RecordFileInfoDao {

	public boolean insert(Connection conn, RecordFileInfo rFileInfo) throws SQLException {
		String sqlInsert = "insert into RecordFile(fileName, songId, status, fileType, uid,duration,score,singTime) values( ? , ? , ? , ? , ? ,?, ?,? )";
		PreparedStatement pstmt = null;
		try{
			pstmt = conn.prepareStatement(sqlInsert);//相当于python操作数据库的游标
			pstmt.setString(1, rFileInfo.getFileName());
			pstmt.setString(2, rFileInfo.getSongId());
			pstmt.setInt(3, rFileInfo.getStatus());
			pstmt.setInt(4, rFileInfo.getFileType());
			pstmt.setInt(5, rFileInfo.getUid());
			pstmt.setLong(6, rFileInfo.getDuration());
			pstmt.setInt(7, rFileInfo.getScore());
			pstmt.setLong(8, rFileInfo.getSingTime());
			pstmt.executeUpdate();
		}catch (Exception e) {
			System.out.println("RecordFileInfoDao insert Exception:"+e);
			return false;
		}
		finally{
			if(pstmt != null){
				pstmt.close();
			}
		}
		
		return true;
	}

}
